package com.bwie.gddproject.index.adapter;

import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bwie.gddproject.R;
import com.bwie.gddproject.index.model.bean.Classify2Bean;

import java.util.List;


/**
 * Created by 我走路带风 on 2017/12/17.
 */

public class RightAdapter extends RecyclerView.Adapter{
    private Context context;
    private List<Classify2Bean.DataBean> list;
    public RightAdapter(FragmentActivity activity, List<Classify2Bean.DataBean> data) {
        this.context = activity;
        this.list = data;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.classify_right,null);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MyHolder holder1 = (MyHolder) holder;
        holder1.right_title.setText(list.get(position).getName());
        List<Classify2Bean.DataBean.ListBean> listbottom = this.list.get(position).getList();
        RightBottom_Adapter rightBottom_adapter = new RightBottom_Adapter(context,listbottom);
        holder1.right_rv.setLayoutManager(new GridLayoutManager(context,3));
        holder1.right_rv.setAdapter(rightBottom_adapter);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    class MyHolder extends RecyclerView.ViewHolder{
        TextView right_title;
        RecyclerView right_rv;
        public MyHolder(View itemView) {
            super(itemView);
            right_title = itemView.findViewById(R.id.right_title);
            right_rv = itemView.findViewById(R.id.right_rv);
        }
    }
}
